const path = require('path');
const { task } = require('gulp');
const plugins = require('gulp-load-plugins')({
  DEBUG: true
});
const data = require('./config/env.config');
const resolve = (dirName) => path.join(__dirname, dirName);

/**
 * @src 查找目录，需处理的源文件；多文件时，其值是数组或正则
 * @desc 输出目录，只能指定要生成文件的目录，而不能指定生成文件的文件名，生成文件的文件名使用的是导入到它的文件流自身的文件名
 */
const pathList = {
  clean: {
    src: [resolve('dist'), resolve('rev'), resolve('tmp')],
  },
  // 结构
  html: {
    src: resolve('src/**/*.html'),
    dest: resolve('dist'),
  },
  ejs: {
    src: resolve('src/**/*.{ejs, html}'),
    dest: resolve('dist'),
  },
  // 样式
  scss: {
    entry: resolve('src/**/*.{scss, sass}'),
    output: resolve('dist'),
  },
  cssInject: {
    cssInput: resolve('dist/**/*.css'),
    htmlInput: resolve('dist/**/*.html'),
    output: resolve('dist'),
  },
  // 行为
  js: {
    entry: resolve('src/**/*.js'),
    output: resolve('dist/js'),
  },
  // 其他
  copy: {
    src: resolve('src/assets/**/*'),
    dest: resolve('dist'),
  },
  favicon: {
    src: resolve('src/assets/images/favicon.png'),
    dest: resolve('dist'),
  },
  images: {
    src: 'src/assets/images/*',
    dest: 'dist/static/',
    watch: 'src/assets/images/*',
  },
  // 服务
  server: {
    src: resolve('dist'),
  },
};

task('test', done => {
  console.log(data);
  done();
});
